/*
 * @Author: 吴让坤
 * @Date: 2023-03-17 23:35:48
 * @LastEditTime: 2023-05-18 12:04:07
 * @Description: 描述
 */
import { fileURLToPath, URL } from 'node:url'
import UnoCSS from 'unocss/vite'
import { defineConfig, loadEnv, type ConfigEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import Components from "unplugin-vue-components/vite"
import AutoImport from "unplugin-auto-import/vite"
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import type { UserConfigExport } from 'vitest/dist/config'

export default ({ command, mode }: ConfigEnv): UserConfigExport => {
  const root = process.cwd();
  const viteEnv = loadEnv(mode, root);
// https://vitejs.dev/config/
return defineConfig({
  plugins: [
    vue(),
    UnoCSS(),
    AutoImport({
      imports: ['vue', 'pinia'],
      resolvers: [ElementPlusResolver()],
      eslintrc: {
        enabled: false
      },
      include: [

      ]
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
    // "inclueds": [

    // ]
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url)),
      '@images': `${fileURLToPath(new URL('./src', import.meta.url))}\\assets\\images`
    }
  },
  server: {
    open: true,
    port: 5927,
    host: true,
    proxy: {
      [viteEnv.VITE_API_BASEPATH]: viteEnv.VITE_API_URL,
    }
  },
})
}
